package com.andnux.android.adapter;

import com.andnux.android.data.OrdersComment;
import com.andnux.android.databinding.ItemOrdersCommentBinding;
import com.andnux.android.network.GsonUtils;
import com.andnux.android.utils.ImageLoader;
import com.google.gson.reflect.TypeToken;

import java.util.List;

public class OrdersCommentAdapter extends BaseAdapter<OrdersComment, ItemOrdersCommentBinding> {

    @Override
    public void onBindView(ItemOrdersCommentBinding binding, OrdersComment comment, int position) {
        super.onBindView(binding, comment, position);
        ImageLoader.load(comment.getCommentUser().getAvatar(), binding.headImage);
        binding.title.setText(comment.getCommentUser().getNickname());
        binding.content.setText(comment.getContent());
        String json = comment.getImages();
        List<String> files = GsonUtils.gson.fromJson(json, new TypeToken<List<String>>() {
        }.getType());
        PhotoAdapter adapter = new PhotoAdapter();
        adapter.setNewData(files);
        binding.images.setAdapter(adapter);
    }
}
